﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace QuanLyKhachSan
{
    public partial class UC_LoaiPhong_Edit : System.Web.UI.UserControl
    {
        private int LoaiPhongID = -1;
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (this.Request.QueryString["LoaiPhongID"] != null)
                {
                    LoaiPhongID = int.Parse(this.Request.QueryString["LoaiPhongID"].ToString());
                }
                if (!Page.IsPostBack)
                {
                    if (LoaiPhongID != -1)
                    {
                        LoaiPhong_Load();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// LoaiPhong_Load
        /// </summary>
        protected void LoaiPhong_Load()
        {
            try
            {
                LoaiPhongInfo item = LoaiPhongBLL.LoaiPhong_GetItem(LoaiPhongID);
                txtTenLau.Text = item.LoaiPhongName;                
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void cmdOK_Click(object sender, EventArgs e)
        {
            try
            {
                string LoaiPhongName = txtTenLau.Text;
                if (LoaiPhongID == -1)
                {
                    LoaiPhongBLL.LoaiPhong_Add(LoaiPhongName);   
                }
                else
                {
                    LoaiPhongBLL.LoaiPhong_Edit(LoaiPhongID,LoaiPhongName);   
                }
                hfStatus.Value = "1";
            }
            catch (Exception)
            {
                
                throw;
            }
        }
}
}
